package com.banmao.greedysnake.util;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

public class SpringContextUtil {

    private static final DefaultListableBeanFactory CONTEXT = new DefaultListableBeanFactory();

    public static Object getBean(String name) {
        Object bean = CONTEXT.getBean(name);
        return bean;
    }

    public static Object getBean(Class<?> clazz) {
        Object bean = CONTEXT.getBean(clazz);
        return bean;
    }

    public static void registerSingleton(String name, Object bean) {
        CONTEXT.registerSingleton(name, bean);
    }

}
